﻿package com.jdplat.jdm.web.service.system.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.shiro.authc.UsernamePasswordToken;
import org.springframework.stereotype.Service;

import com.jdplat.jdm.core.web.service.impl.BaseServiceImpl;
import com.jdplat.jdm.web.entity.User;
import com.jdplat.jdm.web.service.system.ISystemUserService;

/** 
* @author: qirp 
* @time: 2016年12月8日 上午9:59:35 
*/
@Service
public class SystemUserServiceImpl extends BaseServiceImpl implements ISystemUserService{

	public boolean checkLogin(UsernamePasswordToken token) {
		Map<String, Object> map = new HashMap<>();
		map.put("username", token.getUsername());
		map.put("password", String.valueOf(token.getPassword()));
		List<Map<String, String>> userInfo = getDao().queryForList("login_space.checkLogin", map);
		if(userInfo.isEmpty()){
			return false;
		}else{
			return true;
		}
	}

	public User getUserInfo(String username) {
		List<User> user = getDao().queryForList("login_space.getLoginInfo",username);
		if(user.size() > 0){
			return user.get(0);
		}else
		    return null;
	}

	public List<Map<String, Object>> selectUser() {
		return getDao().queryForList("login_space.selectUser");
	}

	public void creatUser(User user) {
		getDao().insert("login_space.creatUser", user);
	}

	public void delUser(String id) {
		getDao().delete("login_space.delUser", id);
	}

}
